DEFINITION MODULE RealConversions;

(* (C) Copyright 1987,1988 Fitted Software Tools. All rights reserved. *)


PROCEDURE RealToString( x :REAL; decDigits, n :INTEGER;
                        VAR s :ARRAY OF CHAR; VAR ok :BOOLEAN );
(*
    Converts x to an ASCII representation.
    n is the width of the ASCII field.
    ABS(decDigits) is the number of decimal digits desired.
    s is where the result is placed.
    ok is set to TRUE is the conversion was successful.

    The output in s is in fixed point notation if decDigits is positive;
    otherwise, x is represented in scientific notation.

    If n is greater than the number of characters needed for the conversion,
    s is padded with spaces on the left.
    If decDigits > 0 then n must be >= decDigits+2
    else n must be >= ABS(decDigits)+7

    Examples:

        RealToString( 1.148, 2, 6, s, ok ) would place in s:
            "  1.15"

        RealToString( 1.148, -2, 10, s, ok ) would place in s:
            "  1.15E+00"
*)

PROCEDURE StringToReal( s :ARRAY OF CHAR; VAR x :REAL; VAR ok :BOOLEAN );
(*
    converts the string s into a REAL number.
    a real in the format defined for Modula-2 REAL literals is expected.
*)

PROCEDURE LongRealToString( x :LONGREAL; decDigits, n :INTEGER;
                            VAR s :ARRAY OF CHAR; VAR ok :BOOLEAN );
(*
    works like RealToString
*)

PROCEDURE StringToLongReal( s :ARRAY OF CHAR;
                            VAR x :LONGREAL; VAR ok :BOOLEAN );
(*
    works like StringToReal
*)


END RealConversions.